package com.zyc.webtest.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * 返回数据
 * 
 * @author zyc
 */
public class ResultMsg extends HashMap<String, Object> {
	private static final long serialVersionUID = 1L;

	public ResultMsg() {
		put("code", 1);
	}
	
	public static ResultMsg error() {
		return error(500, "未知异常，请联系管理员");
	}
	
	public static ResultMsg error(String msg) {
		return error(500, msg);
	}
	
	public static ResultMsg error(int code, String msg) {
		ResultMsg ResultMsg = new ResultMsg();
		ResultMsg.put("code", code);
		ResultMsg.put("msg", msg);
		return ResultMsg;
	}

	public static ResultMsg success(String msg) {
		ResultMsg ResultMsg = new ResultMsg();
		ResultMsg.put("msg", msg);
		return ResultMsg;
	}
	
	public static ResultMsg success(Map<String, Object> map) {
		ResultMsg ResultMsg = new ResultMsg();
		ResultMsg.putAll(map);
		return ResultMsg;
	}
	
	public static ResultMsg success() {
		return new ResultMsg();
	}

	public ResultMsg put(String key, Object value) {
		super.put(key, value);
		return this;
	}
}
